let table_name = "job_identity_picture_table";
let table_data_url = "/sys/job/identity/picture/list";
let number_list = "<'row'<'#mytool.col-xs-3'><'col-xs-9'>><'row'<'.col-xs-12'tr>><'row'<'#num_menu.col-xs-2'l><'col-xs-10'p>>";

function action_status() {
}

let dataManage = {
    currentItem: null,
    fuzzySearch: true,
    getQueryCondition: function (data) {
        let param = {};
        param.start = data.start;
        param.length = data.length;
        return JSON.stringify(param);
    },
};

let returnData = {
    getDate: [
        {
            className: "ellipsis",
            data: "",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        }, {
            className: "ellipsis",
            data: "identityName",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        },{
            className: "ellipsis",
            data: "identityNumber",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        },
        {
            className: "ellipsis",
            data: "identityPicture",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                if (isNotNull(row.identityPicture)) {
                    return '<img alt="" src="http://img.shengongying.cn/' + row.identityPicture + '" width="50px" height="50px">';
                }
            }
        },
        {
            className: "ellipsis",
            data: "",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                let button = '';
                button += '<button class="btn btn-sm btn-success" onclick=job_identity_delete(' + row.id + ')>删除</button>';
                return button;
            }
        }
    ]
}

function foot_info(result) {
}

function createdRow(row, data, index) {
    if (data.role) {
        $(row).addClass("info");
    }
}

function drawCallback(settings) {
}

function search_user() {
    find();
}

function fn_draw_call_back() {
}

function create_job_identity_picture(id) {
    $('#job_identity_picture_modal').modal('show');
}

function job_identity_delete(id) {
    HttpUtils.post_json('/sys/job/identity/picture/delete', JSON.stringify({
        'id': id,
    }), function (result) {
        success_msg("更新成功", function () {
            find();
        });
    });
}


modalClose('job_identity_picture_modal', function () {
    $('#identity_name').val('');
    $('#identity_number').val('');
    image_item_re_init();
});

function save_job_identity_picture() {
    let formdata = new FormData();
    let identity_name = $('#identity_name').val();
    formdata.append("identityName", identity_name);

    let identity_number = $('#identity_number').val();
    formdata.append("identityNumber", identity_number);

    let identity_picture = $('#identity_picture')[0].files[0];
    formdata.append("picture", identity_picture);


    HttpUtils.upload_file('/sys/job/identity/picture/save', formdata, function (result) {
        success_msg("保存成功", function () {
            $('#job_identity_picture_modal').modal('hide');
            find();
        });
    });
}
